package cn.tedu.batch.transformation

import org.apache.flink.api.java.aggregation.Aggregations
import org.apache.flink.api.scala.ExecutionEnvironment

/**
 * @author Amos
 * @date 2022/5/19
 */

object BatchAggregateDemo {
  def main(args: Array[String]): Unit = {
    val env = ExecutionEnvironment.getExecutionEnvironment

    import org.apache.flink.api.scala._
    val source: DataSet[(String, Int)] = env.fromElements(("java", 1), ("java", 5), ("scala", 2), ("scala", 6), ("java", 2))

    // 求最大/最小/求和
    source.groupBy(0).aggregate(Aggregations.MAX,1).print()
    source.groupBy(0).aggregate(Aggregations.MIN,1).print()
    source.groupBy(0).aggregate(Aggregations.SUM,1).print()




  }

}
